package br.com.trophy.games;

import br.com.trophy.R;
import br.com.trophy.Visualizer;
import br.com.trophy.assets.Loader;
import br.com.trophy.parsing.Game;
import br.com.trophy.trophies.MyTrophies;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

public class GameView extends Activity implements Visualizer
{
	// ----------------------------------------------------------------------
	// Atributos de classe
	// ----------------------------------------------------------------------

	// Objetos da tela
	private static EditText editTextName;
	private static ImageView imageview;

	// Intent para manipulaçao de uma tela para outra
	private Intent i;

	// Parametros que serão passados/capturados para/de outra tela
	private String id;
	private String name;
	private String pic;
	private String bigPic;
	private String date;
	private String type;
	private String bronze;
	private String platinum;
	private String gold;
	private String silver;
	private String percDone;
	private Game game;
	

	// ----------------------------------------------------------------------
	// Metodos Sobrecarregados
	// ----------------------------------------------------------------------
	@Override
	protected void onCreate( Bundle savedInstanceState )
	{
		super.onCreate( savedInstanceState );
		setContentView( R.layout.layout_game );

		createViews();
		getExtras();
		setViews();
	}
	// ----------------------------------------------------------------------
	// Metodos publicos
	// ----------------------------------------------------------------------
	public void addObject( View view )
	{
		//i = new Intent( this, AddTrophy.class );
		putExtras();
		startActivity( i );

	}
	// ----------------------------------------------------------------------
	public void listObjects( View view )
	{
		i = new Intent( this, MyTrophies.class );
		putExtras();
		startActivity( i );
	}
	// ----------------------------------------------------------------------
	public void createViews()
	{
		editTextName 		= (EditText) findViewById( R.id.edName );
		imageview			= (ImageView) findViewById( R.id.gameView);
	}
	// ----------------------------------------------------------------------
	public void setViews()
	{
		editTextName.setText( name );
		imageview.setImageDrawable( Loader.LoadImageFromWeb( bigPic ) );
	}
	// ----------------------------------------------------------------------
	// Metodos privados
	// ----------------------------------------------------------------------
	private void getExtras()
	{
		Bundle extras = getIntent().getExtras();
		game 		= (Game)extras.getParcelable( "game" );
		name		= game.getName();
		date 		= game.getdate();
		type 		= game.getType();
		id 			= game.getId();
		pic			= game.getPic();
		bigPic 		= game.getBigPic();
		bronze 		= game.getCountBronze();
		gold 		= game.getCountGold();
		platinum 	= game.getCountPlatinum();
		silver 		= game.getCountSilver();
		percDone 	= game.getPercDone();
	}
	// ----------------------------------------------------------------------
	private void putExtras()
	{
		i.putExtra( "game", game );
	}
}
